/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package banksystem;

import java.util.HashMap;
import java.util.ArrayList;

/**
 *
 * @author conra_000
 */
public final class User {
	private long mID;
	private String mUserName;
	private String mPassword;
	
	private String mFirstName;
	private String mLastName;
	private String mAddress;
	private String mPhoneNumber;
	
	private HashMap<Long, Account> mAccounts = new HashMap<Long, Account>();
	private HashMap<Long, CertificateOfDeposit> mCDs = new HashMap<Long, CertificateOfDeposit>();
	private HashMap<Account, ArrayList<Transaction>> mUserTransactionsMap;
	
	
	public int mPublicInt;
	
	// Used for testing??!?
	public User(long userID) {
		mID = userID;
		mUserTransactionsMap = new HashMap<Account, ArrayList<Transaction>>();
	}
	
	// use for registration!!!
	public User(String userName, String password) {
		mUserName = userName;
		mPassword = password;
		mUserTransactionsMap = new HashMap<Account, ArrayList<Transaction>>();
	}
	
	// gets an Account object from the mAccounts hashmap
	public Account getAccount(long accountID) {
		return mAccounts.get(accountID);
	}
	// gets all of the accounts
	public HashMap<Long, Account> getAccounts() {
		return mAccounts;
	}
	
	// gets an Account object from the mAccounts hashmap
	public CertificateOfDeposit getCD(long accountID) {
		return mCDs.get(accountID);
	}
	// gets all of the CDs
	public HashMap<Long, CertificateOfDeposit> getCDs() {
		return mCDs;
	}
	// creates and stores a new Account in the mAccounts HashMap
	// returns new account ID
	public long addNewAccount() {
		long accountID = System.currentTimeMillis();	
		return addNewAccountCustomID(accountID);
	}
	
	
	public long addNewAccountCustomID(long accountID) {
		Account newAcc = new Account(accountID);
		mAccounts.put(accountID, newAcc);
		mUserTransactionsMap.put(newAcc, newAcc.getTransactionList());
		return accountID;
	}
	
	public long addNewCD(Double amount, CDPackage pac) {
		CertificateOfDeposit newCD = new CertificateOfDeposit(System.currentTimeMillis(), pac);
		newCD.setBalance(amount);
		mCDs.put(newCD.getID(), newCD);
		mUserTransactionsMap.put(newCD, newCD.getTransactionList());
		return newCD.getID();
	}

	public void removeAccount(long accountID) {
		mAccounts.remove(accountID);
		//Do not remove account from UserTransactionsMap, It will be stored 
		//	there for record keeping purposes
	}
	
	public void removeCD(long cdID) {
		mCDs.remove(cdID);
	}
	
	public void setUserName(String userName) {
		mUserName = userName;
	}
	public void setPassword(String password) {
		mPassword = password;
	}
	public void setUserID(long id) {
		mID = id;
	}

	
	public String getUserName() {
		return mUserName;
	}
	public String getPassword() {
		return mPassword;
	}
	
	public long getUserID() {
		return mID;
	}
	
	public void setFirstName(String FirstName) {
		mFirstName = FirstName;
	}
	public String getFirstName() {
		return mFirstName;
	}
	public void setLastName(String LastName) {
		mLastName = LastName;
	}
	public String getLastName() {
		return mLastName;
	}
	public void setAddress(String Address) {
		mAddress = Address;
	}
	public String getAddress() {
		return mAddress;
	}
	public void setPhoneNumber(String PhoneNumber) {
		mPhoneNumber = PhoneNumber;
	}
	public String getPhoneNumber() {
		return mPhoneNumber;
	}
}
